from flask import render_template, redirect, url_for
from application.decorators import login_required, admin_required

from application.reader import *
from application.models import *
import logging

@login_required
def index():
    return render_template('index.html')

@login_required
def authed():
    return render_template('authed.html')

@admin_required
def admin():
    return render_template('admin.html')

def warmup():
    """App Engine warmup handler
    See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests

    """
    logging.info('warmup')
    return 'Ok'

@login_required    
def test():
    mark_item_readed(db.Key(encoded='agtkZXZ-cHlpbmRleHIaCxIEVXNlciIQdGVzdEBleGFtcGxlLmNvbQw'), 
                     db.Key(encoded='agtkZXZ-cHlpbmRleHI4CxIHQ2hhbm5lbCIZaHR0cDovL3d3dy5pZmFuci5jb20vZmVlZAwLEgRJdGVtGICAgICAgICARAw'))
    return 'Ok'
    #return redirect(url_for('subscribe'))